// Thud - a dynamic object-oriented language
// Copyright (C) 2009,2010 David H. Hovemeyer <david.hovemeyer@gmail.com>

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

/*
 * Location.cpp
 *
 *  Created on: Dec 3, 2009
 *      Author: dhovemey
 */

#include <cassert>
#include "util/String.h"
#include "fe/Location.h"

Location::Location(int lineNum)
	: m_lineNum(lineNum)
{
	assert(m_lineNum > 0);
}

Location::Location(const Location &other)
	: m_lineNum(other.m_lineNum)
{
	assert(m_lineNum > 0);
}

Location::~Location()
{
}

Location& Location::operator=(const Location &rhs)
{
	if (this != &rhs) {
		m_lineNum = rhs.m_lineNum;
		assert(m_lineNum > 0);
	}
	return *this;
}

bool Location::isValid() const
{
	return m_lineNum > 0;
}

int Location::getLineNum() const
{
	assert(m_lineNum > 0);
	return m_lineNum;
}

std::wstring Location::asString() const
{
	return L"line " + String::asWString(m_lineNum);
}
